package br.fatec.ads.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.fatec.ads.dao.VagaDAO;
import br.fatec.ads.exception.DataBaseException;
import br.fatec.ads.exception.VagaException;
import br.fatec.ads.model.Vaga;

/**
 * Servlet implementation class VagaConsultar
 */
public class VagaConsultar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public VagaConsultar() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			HttpSession session = request.getSession(false);
			
			Vaga vaga = new Vaga();
			VagaDAO vagaDAO = new VagaDAO();
		
			vaga = vagaDAO.getVaga(Integer.parseInt(request.getParameter("idVagaConsultar")));
			
			 session.setAttribute("vaga", vaga);
			 
			 request.getRequestDispatcher("cadvaga_c.jsp").forward(request, response);
		} catch (VagaException e) {
			e.printStackTrace();
		} catch (DataBaseException e) {
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
